package com.eqxiu.iom.msg.config;

import com.eqxiu.iom.msg.consumer.UserBehaviorEventConsumer;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.adapter.AbstractAdaptableMessageListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

/**
 * @author wangl
 * @description TODO
 * @date 2020-05-31
 */
@Configuration
public class MessagingMessageListenerAdapter extends AbstractAdaptableMessageListener {

    @Autowired
    private UserBehaviorEventConsumer consumer;

    @Override
    public void onMessage(Message message, Channel channel) throws Exception {
        consumer.receiveMessage(message.getBody(), message.getMessageProperties());
    }

    @Override
    public void onMessage(org.springframework.amqp.core.Message amqpMessage) { // NOSONAR
//        consumer.receiveMessage(amqpMessage.getBody(), amqpMessage.getMessageProperties());
        consumer.receiveMessage(amqpMessage);
    }

}
